<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
<title>卓越人生</title>
<link rel="stylesheet" type="text/css" href="/static/css/style.css">
<link rel="stylesheet" type="text/css" href="/static/css/shoujisc.css">
<link rel="stylesheet" type="text/css" href="/static/css/jquery.mobile-1.4.5.min.css">
<link rel="stylesheet" type="text/css" href="/static/css/my.css">
<script type="text/javascript" src="/static/js/jquery-2.0.0.min.js"></script>

<script type="text/javascript" src="/static/js/jquery.mobile-1.4.5.min.js"></script>
<script type="text/javascript" src="/static/js/xujianbanner.js"></script>
<script type="text/javascript" src="/static/js/myinit.js"></script>
<script type="text/javascript" src="/static/js/cook_shop_cart.js"></script>
<style type="text/css">
.ui-input-text {
	height: 32px;
	padding-top: 0px;
	padding-bottom: 0px;
	border: 1px solid #FFB366;
}
.myserch {
	display: inline-block;
	margin-right: 50px;
	margin-left: 50px;
	margin-top: 8px;
}
.ui-input-text input {
	height: 32px;
	line-height: 32px;
	font-size: 14px;
	padding: 0px 0px 0px 0px;
}
 

#banner img{
	position:absolute;
	display:block;
	width:100%;
}
.mypannelshow{
	transform:translateX(0);
	transition-duration:200ms;
}
.mypannelhide{
	transform:translateX(-100px);
	transition-duration:200ms;
}
</style>
<script type="text/javascript">

</script>
</head>

<body>
<div data-role="page" id="home"> 
	
	<!--panner start  -->
	 
 
	 
	
	<!--panner end -->
	
	 <div data-role="header" style="background-color:#FF8000;height:48px;border-bottom-width: 0px;top:0px;border-top-width:0px" data-position="fixed" data-tap-toggle="false"> <img src="/static/img/fenlei.png" style="top:11px;width:25px;height:25px;left:12.5px" class="ui-btn-left" id="tocagagory"><img src="/static/img/tiantianhui.png" style="margin-left: 20px;left:30px;width: 25px;margin-top: 11px;" class="ui-btn-left">
    <input placeholder="请输入您需要的商品" id="serch_input"/>
    <img src="/static/img/sjsc-13.png" style="top:11px;width:25px;height:25px;right:12.5px" class="ui-btn-right" id="serche"> </div>
	
	
	
	
  <!--reallbody start  -->
  
  
  
  
	<div role="main" class="ui-content" style="background-color:#F7F7F7">
		<div data-role="listview" id="cagatorylist" class="mypannelhide" style="overflow:auto;top: 48px;width: 100px;position:fixed;z-index:99;bottom:50px;display:none;background-color:white">
		
		</div>
	
	
	
	
	
	
	
		<div id="banner" style="position:relative;overflow:hidden;min-height:50px;"> <img src="/static/img/banner_1.jpg" style="position:absolute;display:block;width:100%"> <img src="/static/img/banner_2.jpg" style="position:absolute;transition-duration:30000ms;width:100%"> <img src="/static/img/banner_3.jpg" style="position:absolute;transition-duration:30000ms;width:100%"> <img src="/static/img/banner_1.jpg" style="position:absolute;transition-duration:30000ms;width:100%"> </div>
		<div style="height:20px"><div></div></div>
		 
		<div id="cuxiao"></div>
		
		
		<!--
		<div class="sy-ft">
			<div class="sy-ftif1">
				<table border="1" class="sy-tab1" bordercolor="#dbdbdb">
					<tr>
						<td align="center" valign="middle" colspan="1"><a id="todenglu">登录</a></td>
						<td align="center" valign="middle" colspan="1"><a id="tozhuce">注册</a></td>
						<td align="center" valign="middle" colspan="1"><a id="totop">回到顶部</a></td>
						
						
						 
						
						
					</tr>
				</table>
			</div>
			<p class="sy-ft-p1" style="text-align:center">联系电话 400-000-0000</p>
			<p class="sy-ft-p1" style="text-align:center">Copyright 2015-2016 悦生活·享滋味</p>
			<p class="sy-ft-p1" style="text-align:center">ICP备案 *********</p>
		</div>
		-->
        <div>
        <img src="/static/img/1000j50.jpg" style="width:100%;height:auto"/>
        <img src="/static/img/500j20.jpg" style="width:100%;height:auto"/>
        </div>
        <!--多块好省-->
        <div style="width:100%;font-size:12px;"><div style="display:inline-block;width:25%;text-align:center;height:50px;line-height:50px"><img src="/static/img/duo.png" style="display: inline-block; vertical-align: middle;  " height="20px" width="auto">品类齐全</div><div style="display:inline-block;width:25%;text-align:center;height:50px;line-height:50px"><img src="/static/img/kuai.png" style="display: inline-block; vertical-align: middle;  " height="20px" width="auto">多仓直发</div><div style="display:inline-block;width:25%;text-align:center;height:50px;line-height:50px"><img src="/static/img/hao.png" style="display: inline-block; vertical-align: middle;  " height="20px" width="auto">正品行货</div><div style="display:inline-block;text-align:center;height:50px;line-height:50px;width:25%;"><img src="/static/img/sheng.png" style="display: inline-block; vertical-align: middle;  " height="20px" width="auto">天天低价</div></div>
        
       
        
        
        
		<hr style="border-bottom:0px;border-color: rgba(180, 189, 99,0.3);margin-top:0px;margin-bottom:0px">
		
		<div style="text-align:center;background-image:url('/static/img/tiantianhuiwang.png');background-position:center;background-repeat:no-repeat;background-size:auto 50px;height:50px;margin-bottom:50px;background-color: #F7F7F7;"><div></div></div>
		 
		<div style="position:fixed;bottom:60px;right:10px;width:40px;height:40px;display:inline-block;background-position:center;background-image:url('/static/img/backtotop.png');background-repeat:no-repeat;background-size:100% 100%;" id="to_top"></div>
		 
	</div>
	<div data-role="footer" data-position="fixed" data-tap-toggle="false">
		<ul class="quanbu-ul1" id="bottom_menu">
			<li class="current"  id="toindex">
				<div class="qu-tu1"> <a  class="atu1"><img src="/static/img/sjsc-02.png"></a> <a  class="atu2"><img src="/static/img/shouye.png"></a> </div>
				<a class="qu-ul1a" style="color:#313131;">首页</a> </li>
				
			<!-- <li id='talktokefu' > 
				<div class="qu-tu1"> <a href="#" class="atu1"><img src="/static/img/sjsc-16.png"></a> <a href="#" class="atu2"><img src="/static/img/sjsc-16-1.png"></a> </div>
				<a class="qu-ul1a" style="color:#313131">客服在线</a> </li> -->
				
			<li style="position:relative" id="toshoppindlist">
			<div style=" background-color: rgb(210, 36, 36); border-radius: 50px; width: 12px; height: 12px; text-align: center; line-height: 12px; font-size:8px;font-weight:lighter;color: white; right: 25%;position:absolute;display:none;text-shadow:none" id="cart_total"></div>
				<div class="qu-tu1"> <a class="atu1"><img src="/static/img/sjsc-17.png"></a> <a class="atu2"><img src="/static/img/sjsc-17-1.png"></a> </div>
				<a class="qu-ul1a" style="color:#313131">购物车</a> 

				</li>
			<li id="towode">
				<div class="qu-tu1"> <a  class="atu1"><img src="/static/img/sjsc-18.png"></a> <a   class="atu2"><img src="/static/img/sjsc18-1.png"></a> </div>
				<a  class="qu-ul1a" style="color:#313131 ">我的</a> </li>
			<div style="clear:both;"></div>
		</ul>
	</div>
</div>
<script type="text/javascript">
 
	var code = getUrldata('code');
	var openid;
	/*
	function getOpenid(){
		var url = '/weixin/getopenid/';
		var aa={};
		aa.code=code;
		dopost(url,aa,function(oid){
			openid=oid;
			alert(openid);
		});
	}
	*/
	
	function getOpenid(){
		$.post('/weixin/getopenid/',{"code":code},function(aa){
			openid=aa.openid;
			refreshCartTotal();
			cuxiaoall();
		}, "json");

	 
	}
	
	$(document).on('pagebeforeshow','#home',function(){
		
		var ww=$(document).innerWidth();
		$('#home .ui-header .ui-input-text').addClass('myserch');
		$('#home .ui-header .ui-input-text').css('width',ww-100+"px");
		$('#home .ui-header .ui-input-text input').css('width',ww-125+"px");
		$('#home .ui-header .ui-input-text input').css('margin-left',25+"px");
	 	initBanner(277/640);
		
		 
		 
		
	
	 
		
		 
	
	});
	$(document).on('pageshow','#home',function(){
		 
		getOpenid();
	});
	
	
	
	 
	
	$('#tocagagory').click(function(e) {
		
		
		
		if($('#cagatorylist').find('li').length==0){
			initcagatory();
		}else{
			if($('#cagatorylist').hasClass('mypannelshow')){
				$('#cagatorylist').removeClass('mypannelshow');
				$('#cagatorylist').addClass('mypannelhide');
			}else{
				$('#cagatorylist').addClass('mypannelshow');
				$('#cagatorylist').removeClass('mypannelhide');
		
			}
			$('#cagatorylist').show();
		}
		 
	});
	
	function initcagatory(){
		var url = "/webserver/api/v1/catagory/?format=json";
		$.getJSON(url,function(rs){
			var objects=rs.objects;
			$.each(objects,function(index,item){
				$('#cagatorylist').append('<li  id="'+item.id+'">'+item.name+'</li>');
			});
			$('#cagatorylist').listview('refresh');
			$('#cagatorylist li').click(function(e) {
				var id = $(this).attr('id');
				var htm =$(this).html();
				window.location.href="list_by_caga.html?CAGAID="+id+"&HTM="+htm+"&OPENID="+openid;
			});
			
			 
			if($('#cagatorylist').hasClass('mypannelshow')){
				$('#cagatorylist').removeClass('mypannelshow');
				$('#cagatorylist').addClass('mypannelhide');
			}else{
				$('#cagatorylist').addClass('mypannelshow');
				$('#cagatorylist').removeClass('mypannelhide');
		
			}
			$('#cagatorylist').show();
		});
		
	
	}
	
	function refreshCartTotal(){
		var num=cartHelper.getCart().count;
		if(num>0){
			$('#cart_total').html(num);
			$('#cart_total').show();
		}else{
			$('#cart_total').hide();
		}
	}
	
	$('#toindex').click(function(){
		document.location.reload();
	});
	
	$('#toshoppindlist').click(function(){
		window.location.href="shoppinglist.html?OPENID="+openid;
	});
	
	
	$('#tozhuce').click(function(){
		document.location.href="zhuce.html?OPENID="+openid;
	});
	
	
	$('#todenglu').click(function(){
		document.location.href="denglu.html?OPENID="+openid;
	});
	
	$('#towode').click(function(){
		document.location.href="huiyuanshouye.html?code="+code;
	});
	
	
	$('#totop').click(function(){
		$('html,body').animate({scrollTop: '0px'}, 800);
		 
	
	});
	
	function toUrl(url){
		document.location.href=url;
	}
	
	//获取所有的促销
	function cuxiaoall(){
		var url = "/webserver/api/v1/saleinfo/?format=json";
		$.getJSON(url,function(rs){
			var objects = rs.objects;
			
			
			$.each(objects,function(index,item){
				
				var str = item.salename;
				var indexofblank=str.indexOf(' ');
				 
				var eng=str.substr(indexofblank+1);
				
				var chn=str.substr(0,indexofblank);
				$('#cuxiao').append('<div class="ssjg" style="padding-bottom:0;" id="'+item.id+'"><div style="color:#FF9866;font-size:18px;text-align:center;margin-top:-5px;margin-bottom:15px;">'+chn+'</br>'+eng+'</div><div style="clear:both;"></div><ul class="ssjg-ul1" style="padding-top:0;" id="xpss"></ul></div>');
				setTimeout(function(){
					initAcuxiao(item.id);
				},1000*index*5);
				
			});
			
		});
		
	}
	
	function initAcuxiao(cxid){
		var ww=$(document).innerWidth();
		var url = "/webserver/api/v1/good/?format=json&saleinfo="+cxid;
		$.getJSON(url,function(rs){
			var objects = rs.objects;
			$.each(objects,function(index,item){
				$('.ssjg#'+cxid+' ul').append('<li onclick="toUrl(\'xiangqing.html?GOODID='+item.id+'&OPENID='+openid+'\')"><div class="ssjg-tu" style="background-image: url(\''+item.image_thumb+'\'); background-repeat: no-repeat; background-size: 100% auto;height:'+ww*0.48+'px;padding:0px 0px" > </div><h3><a onclick="toUrl(\'xiangqing.html?GOODID='+item.id+'&OPENID='+openid+'\')" style="font-weight:lighter;font-size:14px">'+item.name+'</a></h3><dl class="ssjg-dl1"><dt><p class="ssjg-p1">售价<span>￥'+item.price+'</span></p></dt> <div style="clear:both;"></div></dl></li>');
			});
			$('.ssjg#'+cxid+' ul').append('<div style="clear:both;"></div>');
		});
	
	}
	
	$(document).scroll(function(){
		var scroll_top = $(document).scrollTop();
		var touming = 1;
		if(scroll_top<320){
			touming=scroll_top*1.0/320;
		}
		
		$('#to_top').stop().fadeTo('fast',touming)
		
		
	
	});
	
	$('#to_top').click(function(){
		$('html,body').animate({scrollTop: '0px'}, 800);
	});
	
	$('#serche').click(function(e) {
        var htm=$('#serch_input').val();
		if(htm!=''){
			document.location.href="sousuojieguo.html?OPENID="+openid+"&KEYWORD="+htm;
		}
	});
	
	
	$('#talktokefu').click(function(){
		document.location.href="chatwithkefu.html?OPENID="+openid;
	});
	
	

</script>
</body>
</html>